import request from '@/utils/request'

//API常量
const APIS = {
    V1: "/v1"
}

export function tree(orgId) {
  orgId = orgId === undefined || orgId == "" ? "" : orgId;
    return request({
        url: APIS.V1 + `/system/dept/tree?orgId=`+orgId,
        method: 'get'
    })
}
export function listByPage(params) {
    return request({
        url: APIS.V1 + `/system/dept/listByPage`,
        method: 'get',
        params: params
    })
}

export function deptDistinct() {
    return request({
        url: APIS.V1 + `/system/dept/deptDistinct`,
        method: 'get'
    })
}

export function effectiveDeptDistinct(params) {
  return request({
    url: APIS.V1 + `/system/dept/effectiveDeptDistinct`,
    method: 'get',
    params: params
  })
}

export function getDeptManager(deptManagerId) {
    return request({
        url: APIS.V1 + `/system/dept/getDeptManager?deptManagerId=` + deptManagerId,
        method: 'get'
    })
}

export function deleteById(deptId) {
    return request({
        url: APIS.V1 + `/system/dept/deleteById?deptId=` + deptId,
        method: 'DELETE'
    })
}

export function edit(data) {
    return request({
        url: APIS.V1 + `/system/dept/edit`,
        method: 'post',
        data
    })
}

export function insert(data) {
    return request({
        url: APIS.V1 + `/system/dept/insert`,
        method: 'post',
        data
    })
}

// 禁用或启用账号
export function disableOrEnableAccount(data) {
    return request({
        url: APIS.V1 + `/system/user/disableOrEnableAccount`,
        method: 'POST',
        data
    })
}

// 根据部门id查询还没有选过的员工
export function findNotUserByDeptId(deptId) {
    return request({
        url: APIS.V1 + `/system/deptUser/findNotUserByDeptId?deptId=` + deptId,
        method: 'get'
    })
}

export function insertDeptUser(data) {
    return request({
        url: APIS.V1 + `/system/deptUser/insertDeptUser`,
        method: 'POST',
        data
    })
}

export function findUserByDeptId(param) {
    return request({
        url: APIS.V1 + `/system/deptUser/findUserByDeptId`,
        method: 'get',
        params: param
    })
}

// 查询所有员工
export function findDeptUsers() {
    return request({
        url: APIS.V1 + `/system/deptUser/findDeptUsers`,
        method: 'get'
    })
}
// 移出员工
export function removeUser(userId, deptId) {
    return request({
        url: APIS.V1 + `/system/deptUser/removeUser?userId=` + userId + "&deptId=" + deptId,
        method: 'DELETE'
    })
}

// 禁用
export function disable(detpId) {
    return request({
        url: APIS.V1 + `/system/dept/disable?detpId=` + detpId,
        method: 'post'
    })
}
// 启用
export function enable(detpId) {
    return request({
        url: APIS.V1 + `/system/dept/enable?detpId=` + detpId,
        method: 'post'
    })
}
